{% extends "base.html" %}
{% load static %}

{% block title %}
Admin Dashboard | {{ block.super }}
{% endblock title %}

{% block content %}
{% include "_admin_sidebar.html" %}

<section id="main-content">
    <section class="wrapper">


        <div class="table-agile-info">
            <div class="panel panel-default">
                <section class="panel-heading">{{ view.section_title }}</section>
                <div class="table-responsive">

                    <div class="row w3-res-tb">
                        <div class="col-sm-5 m-b-xs">
                        </div>

                        <div class="col-sm-4">
                        </div>

                        <div class="col-sm-3">
                            {% include "_search_form.html" %}
                        </div>
                    </div>


                    {% if course_list %}
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>Course Name</th>
                            <th>Teachers</th>
                            <th>Operation</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for course in course_list %}
                        <tr>
                            <td>{{ course.pk }}</td>
                            <td>{{ course.full_name }}</td>
                            <td>
                            {% for teacher in course.techers.all %}
                                {% if not teacher.is_superuser  %}
                                    {{ teacher.first_name}} {{ teacher.last_name }}
                                    &nbsp;&nbsp;&nbsp;
                                {% endif %}
                            {% endfor %}
                            </td>
                            <td>
                                <a href="{% url "course:edit" course.id %}">Edit</a>
                                {% comment 'hide for now' %}
                                <a href="{% url "course:update_modules" course.id %}">Update Modules</a>
                                {% if course.modules.count > 0 %}
                                <a href="{% url "course:list_modules" course.modules.first.id %}">Manage Contents</a>
                                {% endif %}
                                {% endcomment %}
                            </td>
                        </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {% else %}
                    <label>No courses yet.</label>
                    {% endif %}

                </div>
            </div>
        </div>
    </section> <!-- /wrapper -->
</section> <!-- /main-content -->

{% endblock content %}
